{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time, re\n",
    "import json\n",
    "from bs4 import BeautifulSoup\n",
    "import requests as sys_requests\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sina_stock_parse(content):\n",
    "    soup = BeautifulSoup(content, \"html.parser\")\n",
    "    stock_name,stock_code = soup.find(id=\"stockName\").get_text().replace('\\n','').split('(')\n",
    "    stock_code=stock_code[:-1].split('.')[0]\n",
    "    \n",
    "    details=soup.find(attrs={\"class\":\"hq_related blue_l a_blue_d_all\"})\n",
    "    data={\"open\":1}\n",
    "    return stock_name,stock_code,details\n",
    "def sina_stock_api_parse(content):\n",
    "    result=content.split('\\n')\n",
    "    return result\n",
    "def sina_industry_parse(content):\n",
    "    content=json.loads(content[content.find('{'):content.find('}',-1)+1])\n",
    "    return content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sina_get_stock_info(code):\n",
    "    url='http://finance.sina.com.cn/realstock/company/%s/nc.shtml' % (code)\n",
    "    response = sys_requests.get(url)\n",
    "    content = str(response.content, 'gbk')\n",
    "    return content\n",
    "def sina_get_stock_info_api(code):\n",
    "    url='http://hq.sinajs.cn/rn=1571242856552&list=%s,%s_i,bk_new_ljhy' % (code,code)\n",
    "    response = sys_requests.get(url)\n",
    "    content = str(response.content, 'gbk')\n",
    "    return content\n",
    "def sina_get_industry_list():\n",
    "    url='http://money.finance.sina.com.cn/q/view/newFLJK.php?param=industry'\n",
    "    response = sys_requests.get(url)\n",
    "    content = str(response.content, 'gbk')\n",
    "    return sina_industry_parse(content)\n",
    "def sina_get_industry_stock_list():\n",
    "    url='http://vip.stock.finance.sina.com.cn/mkt/#hangye_ZF21'\n",
    "    response = sys_requests.get(url)\n",
    "    content = str(response.content, 'gbk')\n",
    "#     soup = BeautifulSoup(content, \"html.parser\")\n",
    "#     content = soup.find(id=\"tbl_wrap\")\n",
    "    return content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('test.html','w+') as file:\n",
    "    file.write(sina_get_industry_stock_list())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "industry=sina_get_industry_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict_table = {\"industry_code\": [], #行业代码\n",
    "              \"industry_name\": [], #行业名称\n",
    "              \"company_num\": [],#公司家数 \n",
    "              'mean_val': [],#平均价格　\n",
    "              'change_amount': [], #涨跌额　　\n",
    "              'Chg': [], #涨跌幅　\n",
    "              'total_volume': [], #总成交量(手)　\n",
    "              'main_stock_code': [], #领涨股 代码\n",
    "              'total_turnover': [], #总成交额(万元)领涨股\t涨跌幅　\n",
    "              'main_stock_Chg': [], #领涨股\t涨跌幅　\n",
    "              'current_price': [], #\t领涨股 当前价　\n",
    "              'main_stock_change_amount': [], #\t领涨股 涨跌额\n",
    "              'main_stock_name': [] #领涨股\n",
    "                  }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "for x in industry:\n",
    "    info=industry[x].split(',')\n",
    "    dict_table[\"industry_code\"].append(info[0])\n",
    "    dict_table[\"industry_name\"].append(info[1])\n",
    "    dict_table[\"company_num\"].append(info[2])\n",
    "    dict_table[\"mean_val\"].append(info[3])\n",
    "    dict_table[\"change_amount\"].append(info[4])\n",
    "    dict_table[\"Chg\"].append(info[5])\n",
    "    dict_table[\"total_volume\"].append(info[6])\n",
    "    dict_table[\"total_turnover\"].append(info[7])\n",
    "    dict_table[\"main_stock_code\"].append(info[8])\n",
    "    dict_table[\"main_stock_Chg\"].append(info[9])\n",
    "    dict_table[\"current_price\"].append(info[10])\n",
    "    dict_table[\"main_stock_change_amount\"].append(info[11])\n",
    "    dict_table[\"main_stock_name\"].append(info[12])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "columns=[\"industry_code\", #行业代码\n",
    "              \"industry_name\", #行业名称\n",
    "              \"company_num\",#公司家数 \n",
    "              'mean_val',#平均价格　\n",
    "              'change_amount', #涨跌额　　\n",
    "              'Chg', #涨跌幅　\n",
    "              'total_volume', #总成交量(手)　\n",
    "              'main_stock_code', #领涨股 代码\n",
    "              'total_turnover', #总成交额(万元)领涨股\t涨跌幅　\n",
    "              'main_stock_Chg', #领涨股 涨跌幅　\n",
    "              'current_price', #领涨股 当前价　\n",
    "              'main_stock_change_amount', #\t领涨股 涨跌额\n",
    "              'main_stock_name' #领涨股\n",
    "        ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.DataFrame(dict_table, columns=columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>industry_code</th>\n",
       "      <th>industry_name</th>\n",
       "      <th>company_num</th>\n",
       "      <th>mean_val</th>\n",
       "      <th>change_amount</th>\n",
       "      <th>Chg</th>\n",
       "      <th>total_volume</th>\n",
       "      <th>main_stock_code</th>\n",
       "      <th>total_turnover</th>\n",
       "      <th>main_stock_Chg</th>\n",
       "      <th>current_price</th>\n",
       "      <th>main_stock_change_amount</th>\n",
       "      <th>main_stock_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>hangye_ZA01</td>\n",
       "      <td>农业</td>\n",
       "      <td>15</td>\n",
       "      <td>7.2946666666667</td>\n",
       "      <td>-0.08</td>\n",
       "      <td>-1.084794792985</td>\n",
       "      <td>55634877</td>\n",
       "      <td>sz300087</td>\n",
       "      <td>368469944</td>\n",
       "      <td>0.820</td>\n",
       "      <td>8.610</td>\n",
       "      <td>0.070</td>\n",
       "      <td>荃银高科</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>hangye_ZA03</td>\n",
       "      <td>林业</td>\n",
       "      <td>5</td>\n",
       "      <td>11.73</td>\n",
       "      <td>-0.068</td>\n",
       "      <td>-0.57636887608069</td>\n",
       "      <td>3775708</td>\n",
       "      <td>sz300087</td>\n",
       "      <td>30644439</td>\n",
       "      <td>0</td>\n",
       "      <td>8.610</td>\n",
       "      <td>0.070</td>\n",
       "      <td>荃银高科</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>hangye_ZA05</td>\n",
       "      <td>畜牧业</td>\n",
       "      <td>10</td>\n",
       "      <td>15.855</td>\n",
       "      <td>-0.805</td>\n",
       "      <td>-4.8319327731092</td>\n",
       "      <td>211847467</td>\n",
       "      <td>sz300087</td>\n",
       "      <td>3436874541</td>\n",
       "      <td>0</td>\n",
       "      <td>8.610</td>\n",
       "      <td>0.070</td>\n",
       "      <td>荃银高科</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>hangye_ZA07</td>\n",
       "      <td>渔业</td>\n",
       "      <td>7</td>\n",
       "      <td>4.7414285714286</td>\n",
       "      <td>-0.12571428571429</td>\n",
       "      <td>-2.5829175227473</td>\n",
       "      <td>111215543</td>\n",
       "      <td>sh600257</td>\n",
       "      <td>395833388</td>\n",
       "      <td>1.099</td>\n",
       "      <td>4.600</td>\n",
       "      <td>0.050</td>\n",
       "      <td>大湖股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>hangye_ZA09</td>\n",
       "      <td>农、林、牧、渔业</td>\n",
       "      <td>2</td>\n",
       "      <td>9.635</td>\n",
       "      <td>0.035</td>\n",
       "      <td>0.36458333333333</td>\n",
       "      <td>14984899</td>\n",
       "      <td>sh603336</td>\n",
       "      <td>81812972</td>\n",
       "      <td>0.623</td>\n",
       "      <td>14.530</td>\n",
       "      <td>0.090</td>\n",
       "      <td>宏辉果蔬</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>hangye_ZB01</td>\n",
       "      <td>煤炭采选业</td>\n",
       "      <td>29</td>\n",
       "      <td>5.389</td>\n",
       "      <td>-0.022178571428571</td>\n",
       "      <td>-0.40986582009465</td>\n",
       "      <td>150540777</td>\n",
       "      <td>sh601918</td>\n",
       "      <td>707288123</td>\n",
       "      <td>10.170</td>\n",
       "      <td>3.250</td>\n",
       "      <td>0.300</td>\n",
       "      <td>新集能源</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>hangye_ZB03</td>\n",
       "      <td>石油和天然气开采业</td>\n",
       "      <td>4</td>\n",
       "      <td>4.9725</td>\n",
       "      <td>-0.0575</td>\n",
       "      <td>-1.1431411530815</td>\n",
       "      <td>99814885</td>\n",
       "      <td>sh601918</td>\n",
       "      <td>525578399</td>\n",
       "      <td>0</td>\n",
       "      <td>3.250</td>\n",
       "      <td>0.300</td>\n",
       "      <td>新集能源</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>hangye_ZB05</td>\n",
       "      <td>黑色金属矿采选业</td>\n",
       "      <td>8</td>\n",
       "      <td>5.775</td>\n",
       "      <td>-0.00625</td>\n",
       "      <td>-0.10810810810811</td>\n",
       "      <td>21468170</td>\n",
       "      <td>sh600193</td>\n",
       "      <td>94923552</td>\n",
       "      <td>3.824</td>\n",
       "      <td>3.530</td>\n",
       "      <td>0.130</td>\n",
       "      <td>ST创兴</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>hangye_ZB07</td>\n",
       "      <td>有色金属矿采选业</td>\n",
       "      <td>18</td>\n",
       "      <td>9.0683333333333</td>\n",
       "      <td>-0.012222222222222</td>\n",
       "      <td>-0.1345977363108</td>\n",
       "      <td>145318864</td>\n",
       "      <td>sz000758</td>\n",
       "      <td>1294614455</td>\n",
       "      <td>0.491</td>\n",
       "      <td>4.090</td>\n",
       "      <td>0.020</td>\n",
       "      <td>中色股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>hangye_ZB50</td>\n",
       "      <td>采掘服务业</td>\n",
       "      <td>12</td>\n",
       "      <td>7.9941666666667</td>\n",
       "      <td>0.045833333333333</td>\n",
       "      <td>0.57664080520025</td>\n",
       "      <td>52724746</td>\n",
       "      <td>sz002683</td>\n",
       "      <td>483178849</td>\n",
       "      <td>3.971</td>\n",
       "      <td>14.400</td>\n",
       "      <td>0.550</td>\n",
       "      <td>宏大爆破</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>hangye_ZC0</td>\n",
       "      <td>食品、饮料</td>\n",
       "      <td>100</td>\n",
       "      <td>29.609191919192</td>\n",
       "      <td>-0.098474747474747</td>\n",
       "      <td>-0.33147923928082</td>\n",
       "      <td>780267287</td>\n",
       "      <td>sz002626</td>\n",
       "      <td>14703077001</td>\n",
       "      <td>9.875</td>\n",
       "      <td>19.360</td>\n",
       "      <td>1.740</td>\n",
       "      <td>金达威</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>hangye_ZC1</td>\n",
       "      <td>纺织、服装、皮毛</td>\n",
       "      <td>88</td>\n",
       "      <td>6.9776823529412</td>\n",
       "      <td>-0.043152941176471</td>\n",
       "      <td>-0.61464112699846</td>\n",
       "      <td>381296154</td>\n",
       "      <td>sh600070</td>\n",
       "      <td>2614553285</td>\n",
       "      <td>9.498</td>\n",
       "      <td>10.030</td>\n",
       "      <td>0.870</td>\n",
       "      <td>浙江富润</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>hangye_ZC2</td>\n",
       "      <td>木材、家具</td>\n",
       "      <td>18</td>\n",
       "      <td>9.7666666666667</td>\n",
       "      <td>-0.13333333333333</td>\n",
       "      <td>-1.3468013468013</td>\n",
       "      <td>104113827</td>\n",
       "      <td>sz002631</td>\n",
       "      <td>842503623</td>\n",
       "      <td>2.789</td>\n",
       "      <td>7.740</td>\n",
       "      <td>0.210</td>\n",
       "      <td>德尔未来</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>hangye_ZC3</td>\n",
       "      <td>造纸、印刷</td>\n",
       "      <td>52</td>\n",
       "      <td>7.7671153846154</td>\n",
       "      <td>0.0051923076923077</td>\n",
       "      <td>0.066894603835291</td>\n",
       "      <td>451227860</td>\n",
       "      <td>sh603022</td>\n",
       "      <td>3480396294</td>\n",
       "      <td>10.038</td>\n",
       "      <td>14.690</td>\n",
       "      <td>1.340</td>\n",
       "      <td>新通联</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>hangye_ZC4</td>\n",
       "      <td>石油化工、塑胶塑料</td>\n",
       "      <td>100</td>\n",
       "      <td>10.578313131313</td>\n",
       "      <td>-0.023222222222222</td>\n",
       "      <td>-0.219045840511</td>\n",
       "      <td>450879989</td>\n",
       "      <td>sh601113</td>\n",
       "      <td>2999975884</td>\n",
       "      <td>4.908</td>\n",
       "      <td>3.420</td>\n",
       "      <td>0.160</td>\n",
       "      <td>ST华鼎</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>hangye_ZC5</td>\n",
       "      <td>电子</td>\n",
       "      <td>100</td>\n",
       "      <td>14.42652</td>\n",
       "      <td>-0.06464</td>\n",
       "      <td>-0.44606504931282</td>\n",
       "      <td>800568892</td>\n",
       "      <td>sz300256</td>\n",
       "      <td>10133319183</td>\n",
       "      <td>10.075</td>\n",
       "      <td>5.900</td>\n",
       "      <td>0.540</td>\n",
       "      <td>星星科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>hangye_ZC6</td>\n",
       "      <td>金属、非金属</td>\n",
       "      <td>100</td>\n",
       "      <td>7.92997</td>\n",
       "      <td>-0.05706</td>\n",
       "      <td>-0.71440823434994</td>\n",
       "      <td>527828745</td>\n",
       "      <td>sh600331</td>\n",
       "      <td>2921607175</td>\n",
       "      <td>10.040</td>\n",
       "      <td>2.740</td>\n",
       "      <td>0.250</td>\n",
       "      <td>宏达股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>hangye_ZC7</td>\n",
       "      <td>机械、设备、仪表</td>\n",
       "      <td>100</td>\n",
       "      <td>12.812595959596</td>\n",
       "      <td>-0.10372727272727</td>\n",
       "      <td>-0.80307120580332</td>\n",
       "      <td>245949309</td>\n",
       "      <td>sh603197</td>\n",
       "      <td>2355922516</td>\n",
       "      <td>2.645</td>\n",
       "      <td>24.450</td>\n",
       "      <td>0.630</td>\n",
       "      <td>保隆科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>hangye_ZC8</td>\n",
       "      <td>医药、生物制品</td>\n",
       "      <td>100</td>\n",
       "      <td>16.63593</td>\n",
       "      <td>-0.14572</td>\n",
       "      <td>-0.86832939550044</td>\n",
       "      <td>584515681</td>\n",
       "      <td>sh600267</td>\n",
       "      <td>7604813888</td>\n",
       "      <td>9.979</td>\n",
       "      <td>10.580</td>\n",
       "      <td>0.960</td>\n",
       "      <td>海正药业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>hangye_ZC99</td>\n",
       "      <td>其他制造业</td>\n",
       "      <td>25</td>\n",
       "      <td>10.16396</td>\n",
       "      <td>-0.1832</td>\n",
       "      <td>-1.7705341369033</td>\n",
       "      <td>175326565</td>\n",
       "      <td>sz300116</td>\n",
       "      <td>1061588532</td>\n",
       "      <td>2.721</td>\n",
       "      <td>1.510</td>\n",
       "      <td>0.040</td>\n",
       "      <td>坚瑞沃能</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>hangye_ZD01</td>\n",
       "      <td>电力、供水供气业</td>\n",
       "      <td>65</td>\n",
       "      <td>5.9316153846154</td>\n",
       "      <td>-0.015892307692308</td>\n",
       "      <td>-0.26720953573313</td>\n",
       "      <td>241799305</td>\n",
       "      <td>sh600116</td>\n",
       "      <td>1390464436</td>\n",
       "      <td>1.897</td>\n",
       "      <td>7.520</td>\n",
       "      <td>0.140</td>\n",
       "      <td>三峡水利</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>hangye_ZD03</td>\n",
       "      <td>煤气生产和供应业</td>\n",
       "      <td>5</td>\n",
       "      <td>8.95</td>\n",
       "      <td>-0.126</td>\n",
       "      <td>-1.3882767739092</td>\n",
       "      <td>35505025</td>\n",
       "      <td>sh600116</td>\n",
       "      <td>242431835</td>\n",
       "      <td>0</td>\n",
       "      <td>7.520</td>\n",
       "      <td>0.140</td>\n",
       "      <td>三峡水利</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>hangye_ZD05</td>\n",
       "      <td>自来水生产供应业</td>\n",
       "      <td>11</td>\n",
       "      <td>7.7327272727273</td>\n",
       "      <td>-0.058181818181818</td>\n",
       "      <td>-0.74679113185531</td>\n",
       "      <td>19635375</td>\n",
       "      <td>sh601199</td>\n",
       "      <td>184544271</td>\n",
       "      <td>0.533</td>\n",
       "      <td>3.770</td>\n",
       "      <td>0.020</td>\n",
       "      <td>江南水务</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>hangye_ZE01</td>\n",
       "      <td>土木工程建筑业</td>\n",
       "      <td>53</td>\n",
       "      <td>5.9002</td>\n",
       "      <td>-0.0138</td>\n",
       "      <td>-0.23334460601961</td>\n",
       "      <td>386018480</td>\n",
       "      <td>sz002586</td>\n",
       "      <td>2197007345</td>\n",
       "      <td>4.706</td>\n",
       "      <td>3.560</td>\n",
       "      <td>0.160</td>\n",
       "      <td>ST围海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>hangye_ZE05</td>\n",
       "      <td>装修装饰业</td>\n",
       "      <td>17</td>\n",
       "      <td>7.3846666666667</td>\n",
       "      <td>-0.066</td>\n",
       "      <td>-0.88582677165354</td>\n",
       "      <td>29599870</td>\n",
       "      <td>sh603929</td>\n",
       "      <td>184923018</td>\n",
       "      <td>1.050</td>\n",
       "      <td>14.440</td>\n",
       "      <td>0.150</td>\n",
       "      <td>亚翔集成</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>hangye_ZF01</td>\n",
       "      <td>铁路运输业</td>\n",
       "      <td>3</td>\n",
       "      <td>5.53</td>\n",
       "      <td>0.0066666666666667</td>\n",
       "      <td>0.12070006035003</td>\n",
       "      <td>19026237</td>\n",
       "      <td>sh600125</td>\n",
       "      <td>95504892</td>\n",
       "      <td>0.344</td>\n",
       "      <td>5.840</td>\n",
       "      <td>0.020</td>\n",
       "      <td>铁龙物流</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>hangye_ZF03</td>\n",
       "      <td>公路运输业</td>\n",
       "      <td>11</td>\n",
       "      <td>6.6817272727273</td>\n",
       "      <td>-0.020636363636364</td>\n",
       "      <td>-0.30789680709655</td>\n",
       "      <td>19298638</td>\n",
       "      <td>sh600119</td>\n",
       "      <td>158707207</td>\n",
       "      <td>4.469</td>\n",
       "      <td>5.610</td>\n",
       "      <td>0.240</td>\n",
       "      <td>*ST长投</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>hangye_ZF05</td>\n",
       "      <td>管道运输业</td>\n",
       "      <td>2</td>\n",
       "      <td>4.645</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-1.9007391763464</td>\n",
       "      <td>10932620</td>\n",
       "      <td>sh600119</td>\n",
       "      <td>50774006</td>\n",
       "      <td>0</td>\n",
       "      <td>5.610</td>\n",
       "      <td>0.240</td>\n",
       "      <td>*ST长投</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>hangye_ZF07</td>\n",
       "      <td>水上运输业</td>\n",
       "      <td>16</td>\n",
       "      <td>4.83475</td>\n",
       "      <td>-0.07175</td>\n",
       "      <td>-1.4623458677265</td>\n",
       "      <td>117142736</td>\n",
       "      <td>sz002320</td>\n",
       "      <td>613503394</td>\n",
       "      <td>0.726</td>\n",
       "      <td>8.320</td>\n",
       "      <td>0.060</td>\n",
       "      <td>海峡股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>hangye_ZF09</td>\n",
       "      <td>航空运输业</td>\n",
       "      <td>9</td>\n",
       "      <td>10.694333333333</td>\n",
       "      <td>-0.191</td>\n",
       "      <td>-1.7546545810877</td>\n",
       "      <td>81170883</td>\n",
       "      <td>sz200152</td>\n",
       "      <td>563032699</td>\n",
       "      <td>1.826</td>\n",
       "      <td>9.480</td>\n",
       "      <td>0.170</td>\n",
       "      <td>山 航Ｂ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>hangye_ZF21</td>\n",
       "      <td>仓储业</td>\n",
       "      <td>6</td>\n",
       "      <td>6.7083333333333</td>\n",
       "      <td>0.175</td>\n",
       "      <td>2.6785714285714</td>\n",
       "      <td>75650519</td>\n",
       "      <td>sz300240</td>\n",
       "      <td>471485986</td>\n",
       "      <td>9.973</td>\n",
       "      <td>8.160</td>\n",
       "      <td>0.740</td>\n",
       "      <td>飞力达</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>hangye_ZG81</td>\n",
       "      <td>通信及相关设备业</td>\n",
       "      <td>65</td>\n",
       "      <td>12.583421875</td>\n",
       "      <td>-0.00290625</td>\n",
       "      <td>-0.023090531020142</td>\n",
       "      <td>475282184</td>\n",
       "      <td>sh603118</td>\n",
       "      <td>5663280354</td>\n",
       "      <td>3.772</td>\n",
       "      <td>12.380</td>\n",
       "      <td>0.450</td>\n",
       "      <td>共进股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>hangye_ZG83</td>\n",
       "      <td>计算机及相关设备业</td>\n",
       "      <td>17</td>\n",
       "      <td>13.556470588235</td>\n",
       "      <td>0.0029411764705882</td>\n",
       "      <td>0.021700447029209</td>\n",
       "      <td>508244492</td>\n",
       "      <td>sz000977</td>\n",
       "      <td>6443642193</td>\n",
       "      <td>5.822</td>\n",
       "      <td>26.900</td>\n",
       "      <td>1.480</td>\n",
       "      <td>浪潮信息</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>hangye_ZG85</td>\n",
       "      <td>通信服务业</td>\n",
       "      <td>24</td>\n",
       "      <td>8.6745833333333</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.69649334945586</td>\n",
       "      <td>250092276</td>\n",
       "      <td>sh603322</td>\n",
       "      <td>1894054353</td>\n",
       "      <td>9.985</td>\n",
       "      <td>21.700</td>\n",
       "      <td>1.970</td>\n",
       "      <td>超讯通信</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>hangye_ZG87</td>\n",
       "      <td>计算机应用服务业</td>\n",
       "      <td>100</td>\n",
       "      <td>18.85507</td>\n",
       "      <td>-0.17663</td>\n",
       "      <td>-0.92808314548884</td>\n",
       "      <td>884875337</td>\n",
       "      <td>sz300226</td>\n",
       "      <td>13369744333</td>\n",
       "      <td>2.712</td>\n",
       "      <td>69.680</td>\n",
       "      <td>1.840</td>\n",
       "      <td>上海钢联</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>hangye_ZH01</td>\n",
       "      <td>食品饮料、家用批发</td>\n",
       "      <td>16</td>\n",
       "      <td>20.614375</td>\n",
       "      <td>-0.159375</td>\n",
       "      <td>-0.76719417534148</td>\n",
       "      <td>41325969</td>\n",
       "      <td>sz000963</td>\n",
       "      <td>652142013</td>\n",
       "      <td>1.484</td>\n",
       "      <td>25.990</td>\n",
       "      <td>0.380</td>\n",
       "      <td>华东医药</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>hangye_ZH03</td>\n",
       "      <td>能源、材料和机电业</td>\n",
       "      <td>26</td>\n",
       "      <td>6.7312307692308</td>\n",
       "      <td>-0.060576923076923</td>\n",
       "      <td>-0.89191163562437</td>\n",
       "      <td>76171501</td>\n",
       "      <td>sz000829</td>\n",
       "      <td>476887628</td>\n",
       "      <td>2.911</td>\n",
       "      <td>6.010</td>\n",
       "      <td>0.170</td>\n",
       "      <td>天音控股</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>hangye_ZH11</td>\n",
       "      <td>零售业</td>\n",
       "      <td>99</td>\n",
       "      <td>9.472193877551</td>\n",
       "      <td>0.031622448979592</td>\n",
       "      <td>0.33496329347065</td>\n",
       "      <td>408674487</td>\n",
       "      <td>sz300755</td>\n",
       "      <td>3484980474</td>\n",
       "      <td>5.100</td>\n",
       "      <td>26.170</td>\n",
       "      <td>1.270</td>\n",
       "      <td>华致酒行</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>hangye_ZH21</td>\n",
       "      <td>商业经纪与代理业</td>\n",
       "      <td>38</td>\n",
       "      <td>7.4680540540541</td>\n",
       "      <td>-0.018189189189189</td>\n",
       "      <td>-0.24296818308176</td>\n",
       "      <td>94790877</td>\n",
       "      <td>sh600787</td>\n",
       "      <td>738966773</td>\n",
       "      <td>2.299</td>\n",
       "      <td>5.340</td>\n",
       "      <td>0.120</td>\n",
       "      <td>中储股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>hangye_ZI01</td>\n",
       "      <td>银行业</td>\n",
       "      <td>31</td>\n",
       "      <td>9.0767741935484</td>\n",
       "      <td>-0.075483870967742</td>\n",
       "      <td>-0.82475680248132</td>\n",
       "      <td>920990113</td>\n",
       "      <td>sz002142</td>\n",
       "      <td>7510286480</td>\n",
       "      <td>1.268</td>\n",
       "      <td>27.160</td>\n",
       "      <td>0.340</td>\n",
       "      <td>宁波银行</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>hangye_ZI11</td>\n",
       "      <td>保险业</td>\n",
       "      <td>6</td>\n",
       "      <td>36.765</td>\n",
       "      <td>-0.17833333333333</td>\n",
       "      <td>-0.48272128485067</td>\n",
       "      <td>70608121</td>\n",
       "      <td>sh601628</td>\n",
       "      <td>2859513318</td>\n",
       "      <td>1.820</td>\n",
       "      <td>33.000</td>\n",
       "      <td>0.590</td>\n",
       "      <td>中国人寿</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>hangye_ZI21</td>\n",
       "      <td>证券、期货业</td>\n",
       "      <td>36</td>\n",
       "      <td>10.1625</td>\n",
       "      <td>-0.00055555555555555</td>\n",
       "      <td>-0.005466422499795</td>\n",
       "      <td>355105820</td>\n",
       "      <td>sh601990</td>\n",
       "      <td>3920716118</td>\n",
       "      <td>2.513</td>\n",
       "      <td>8.160</td>\n",
       "      <td>0.200</td>\n",
       "      <td>南京证券</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>hangye_ZI31</td>\n",
       "      <td>金融信托业</td>\n",
       "      <td>2</td>\n",
       "      <td>4.16</td>\n",
       "      <td>-0.065</td>\n",
       "      <td>-1.5384615384615</td>\n",
       "      <td>23422470</td>\n",
       "      <td>sh601990</td>\n",
       "      <td>98055008</td>\n",
       "      <td>0</td>\n",
       "      <td>8.160</td>\n",
       "      <td>0.200</td>\n",
       "      <td>南京证券</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>hangye_ZI99</td>\n",
       "      <td>其他金融业</td>\n",
       "      <td>1</td>\n",
       "      <td>5.97</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2535700</td>\n",
       "      <td>sh601990</td>\n",
       "      <td>15159163</td>\n",
       "      <td>0</td>\n",
       "      <td>8.160</td>\n",
       "      <td>0.200</td>\n",
       "      <td>南京证券</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>hangye_ZJ09</td>\n",
       "      <td>房地产中介服务业</td>\n",
       "      <td>3</td>\n",
       "      <td>3.671</td>\n",
       "      <td>-0.026</td>\n",
       "      <td>-0.70327292399243</td>\n",
       "      <td>14913221</td>\n",
       "      <td>sh601990</td>\n",
       "      <td>92924735</td>\n",
       "      <td>0</td>\n",
       "      <td>8.160</td>\n",
       "      <td>0.200</td>\n",
       "      <td>南京证券</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>hangye_ZJ01</td>\n",
       "      <td>房地产开发与经营业</td>\n",
       "      <td>100</td>\n",
       "      <td>6.6759081632653</td>\n",
       "      <td>-0.015357142857143</td>\n",
       "      <td>-0.22951029670115</td>\n",
       "      <td>577940732</td>\n",
       "      <td>sh600208</td>\n",
       "      <td>4653411202</td>\n",
       "      <td>10.130</td>\n",
       "      <td>4.240</td>\n",
       "      <td>0.390</td>\n",
       "      <td>新湖中宝</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>hangye_ZJ05</td>\n",
       "      <td>房地产管理业</td>\n",
       "      <td>7</td>\n",
       "      <td>3.5671428571429</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.83399523431295</td>\n",
       "      <td>71824634</td>\n",
       "      <td>sz000882</td>\n",
       "      <td>220281050</td>\n",
       "      <td>3.930</td>\n",
       "      <td>2.380</td>\n",
       "      <td>0.090</td>\n",
       "      <td>华联股份</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>hangye_ZK01</td>\n",
       "      <td>公共设施服务业</td>\n",
       "      <td>13</td>\n",
       "      <td>7.3063846153846</td>\n",
       "      <td>-0.0097692307692308</td>\n",
       "      <td>-0.13352959730838</td>\n",
       "      <td>24086440</td>\n",
       "      <td>sz300388</td>\n",
       "      <td>187253066</td>\n",
       "      <td>1.782</td>\n",
       "      <td>10.280</td>\n",
       "      <td>0.180</td>\n",
       "      <td>国祯环保</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>hangye_ZK20</td>\n",
       "      <td>专业、科研服务业</td>\n",
       "      <td>32</td>\n",
       "      <td>13.1746875</td>\n",
       "      <td>-0.0328125</td>\n",
       "      <td>-0.24843838727995</td>\n",
       "      <td>171703783</td>\n",
       "      <td>sz300070</td>\n",
       "      <td>1410571102</td>\n",
       "      <td>5.184</td>\n",
       "      <td>7.710</td>\n",
       "      <td>0.380</td>\n",
       "      <td>碧水源</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>hangye_ZK30</td>\n",
       "      <td>餐饮业</td>\n",
       "      <td>6</td>\n",
       "      <td>9.6016666666667</td>\n",
       "      <td>0.0033333333333333</td>\n",
       "      <td>0.03472825143254</td>\n",
       "      <td>10606960</td>\n",
       "      <td>sz000796</td>\n",
       "      <td>61974947</td>\n",
       "      <td>2.532</td>\n",
       "      <td>6.480</td>\n",
       "      <td>0.160</td>\n",
       "      <td>凯撒旅游</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>hangye_ZK32</td>\n",
       "      <td>旅馆业</td>\n",
       "      <td>9</td>\n",
       "      <td>8.3553333333333</td>\n",
       "      <td>0.029666666666667</td>\n",
       "      <td>0.35632782159587</td>\n",
       "      <td>10014073</td>\n",
       "      <td>sh600754</td>\n",
       "      <td>145201848</td>\n",
       "      <td>3.879</td>\n",
       "      <td>22.230</td>\n",
       "      <td>0.830</td>\n",
       "      <td>锦江酒店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>hangye_ZK34</td>\n",
       "      <td>旅游业</td>\n",
       "      <td>26</td>\n",
       "      <td>13.613807692308</td>\n",
       "      <td>-0.048307692307692</td>\n",
       "      <td>-0.35358867164956</td>\n",
       "      <td>40355369</td>\n",
       "      <td>sh603869</td>\n",
       "      <td>732070455</td>\n",
       "      <td>2.597</td>\n",
       "      <td>13.430</td>\n",
       "      <td>0.340</td>\n",
       "      <td>新智认知</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>hangye_ZK37</td>\n",
       "      <td>卫生、保健、护理业</td>\n",
       "      <td>3</td>\n",
       "      <td>53.3</td>\n",
       "      <td>-0.19333333333333</td>\n",
       "      <td>-0.36141575274177</td>\n",
       "      <td>18377825</td>\n",
       "      <td>sz300244</td>\n",
       "      <td>893115108</td>\n",
       "      <td>1.403</td>\n",
       "      <td>21.690</td>\n",
       "      <td>0.300</td>\n",
       "      <td>迪安诊断</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>hangye_ZK39</td>\n",
       "      <td>租赁服务业</td>\n",
       "      <td>5</td>\n",
       "      <td>8.76</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>-0.68027210884354</td>\n",
       "      <td>25827862</td>\n",
       "      <td>sh600007</td>\n",
       "      <td>144127520</td>\n",
       "      <td>0.882</td>\n",
       "      <td>17.150</td>\n",
       "      <td>0.150</td>\n",
       "      <td>中国国贸</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>hangye_ZK99</td>\n",
       "      <td>其他社会服务业</td>\n",
       "      <td>19</td>\n",
       "      <td>7.7473684210526</td>\n",
       "      <td>0.015263157894737</td>\n",
       "      <td>0.19739976856579</td>\n",
       "      <td>98302180</td>\n",
       "      <td>sz002183</td>\n",
       "      <td>561450175</td>\n",
       "      <td>2.626</td>\n",
       "      <td>4.690</td>\n",
       "      <td>0.120</td>\n",
       "      <td>怡 亚 通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>hangye_ZL01</td>\n",
       "      <td>出版业</td>\n",
       "      <td>14</td>\n",
       "      <td>7.9864285714286</td>\n",
       "      <td>-0.062142857142857</td>\n",
       "      <td>-0.77209797657082</td>\n",
       "      <td>48060961</td>\n",
       "      <td>sh600373</td>\n",
       "      <td>377126280</td>\n",
       "      <td>1.623</td>\n",
       "      <td>11.900</td>\n",
       "      <td>0.190</td>\n",
       "      <td>中文传媒</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>hangye_ZL10</td>\n",
       "      <td>广播电影电视业</td>\n",
       "      <td>14</td>\n",
       "      <td>8.3785714285714</td>\n",
       "      <td>-0.048571428571429</td>\n",
       "      <td>-0.57636887608069</td>\n",
       "      <td>64381725</td>\n",
       "      <td>sz002905</td>\n",
       "      <td>472582627</td>\n",
       "      <td>1.350</td>\n",
       "      <td>15.020</td>\n",
       "      <td>0.200</td>\n",
       "      <td>金逸影视</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>hangye_ZL20</td>\n",
       "      <td>信息传播服务业</td>\n",
       "      <td>11</td>\n",
       "      <td>8.693</td>\n",
       "      <td>-0.236</td>\n",
       "      <td>-2.6430731324896</td>\n",
       "      <td>88682370</td>\n",
       "      <td>sz002905</td>\n",
       "      <td>874242843</td>\n",
       "      <td>0</td>\n",
       "      <td>15.020</td>\n",
       "      <td>0.200</td>\n",
       "      <td>金逸影视</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>hangye_ZL99</td>\n",
       "      <td>其他传播、文化产业</td>\n",
       "      <td>2</td>\n",
       "      <td>10.715</td>\n",
       "      <td>-0.065</td>\n",
       "      <td>-0.60296846011132</td>\n",
       "      <td>20679105</td>\n",
       "      <td>sh600661</td>\n",
       "      <td>67799874</td>\n",
       "      <td>0.273</td>\n",
       "      <td>18.400</td>\n",
       "      <td>0.050</td>\n",
       "      <td>昂立教育</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>--</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>62 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   industry_code industry_name company_num         mean_val  \\\n",
       "0    hangye_ZA01            农业          15  7.2946666666667   \n",
       "1    hangye_ZA03            林业           5            11.73   \n",
       "2    hangye_ZA05           畜牧业          10           15.855   \n",
       "3    hangye_ZA07            渔业           7  4.7414285714286   \n",
       "4    hangye_ZA09      农、林、牧、渔业           2            9.635   \n",
       "5    hangye_ZB01         煤炭采选业          29            5.389   \n",
       "6    hangye_ZB03     石油和天然气开采业           4           4.9725   \n",
       "7    hangye_ZB05      黑色金属矿采选业           8            5.775   \n",
       "8    hangye_ZB07      有色金属矿采选业          18  9.0683333333333   \n",
       "9    hangye_ZB50         采掘服务业          12  7.9941666666667   \n",
       "10    hangye_ZC0         食品、饮料         100  29.609191919192   \n",
       "11    hangye_ZC1      纺织、服装、皮毛          88  6.9776823529412   \n",
       "12    hangye_ZC2         木材、家具          18  9.7666666666667   \n",
       "13    hangye_ZC3         造纸、印刷          52  7.7671153846154   \n",
       "14    hangye_ZC4     石油化工、塑胶塑料         100  10.578313131313   \n",
       "15    hangye_ZC5            电子         100         14.42652   \n",
       "16    hangye_ZC6        金属、非金属         100          7.92997   \n",
       "17    hangye_ZC7      机械、设备、仪表         100  12.812595959596   \n",
       "18    hangye_ZC8       医药、生物制品         100         16.63593   \n",
       "19   hangye_ZC99         其他制造业          25         10.16396   \n",
       "20   hangye_ZD01      电力、供水供气业          65  5.9316153846154   \n",
       "21   hangye_ZD03      煤气生产和供应业           5             8.95   \n",
       "22   hangye_ZD05      自来水生产供应业          11  7.7327272727273   \n",
       "23   hangye_ZE01       土木工程建筑业          53           5.9002   \n",
       "24   hangye_ZE05         装修装饰业          17  7.3846666666667   \n",
       "25   hangye_ZF01         铁路运输业           3             5.53   \n",
       "26   hangye_ZF03         公路运输业          11  6.6817272727273   \n",
       "27   hangye_ZF05         管道运输业           2            4.645   \n",
       "28   hangye_ZF07         水上运输业          16          4.83475   \n",
       "29   hangye_ZF09         航空运输业           9  10.694333333333   \n",
       "..           ...           ...         ...              ...   \n",
       "32   hangye_ZF21           仓储业           6  6.7083333333333   \n",
       "33   hangye_ZG81      通信及相关设备业          65     12.583421875   \n",
       "34   hangye_ZG83     计算机及相关设备业          17  13.556470588235   \n",
       "35   hangye_ZG85         通信服务业          24  8.6745833333333   \n",
       "36   hangye_ZG87      计算机应用服务业         100         18.85507   \n",
       "37   hangye_ZH01     食品饮料、家用批发          16        20.614375   \n",
       "38   hangye_ZH03     能源、材料和机电业          26  6.7312307692308   \n",
       "39   hangye_ZH11           零售业          99   9.472193877551   \n",
       "40   hangye_ZH21      商业经纪与代理业          38  7.4680540540541   \n",
       "41   hangye_ZI01           银行业          31  9.0767741935484   \n",
       "42   hangye_ZI11           保险业           6           36.765   \n",
       "43   hangye_ZI21        证券、期货业          36          10.1625   \n",
       "44   hangye_ZI31         金融信托业           2             4.16   \n",
       "45   hangye_ZI99         其他金融业           1             5.97   \n",
       "46   hangye_ZJ09      房地产中介服务业           3            3.671   \n",
       "47   hangye_ZJ01     房地产开发与经营业         100  6.6759081632653   \n",
       "48   hangye_ZJ05        房地产管理业           7  3.5671428571429   \n",
       "49   hangye_ZK01       公共设施服务业          13  7.3063846153846   \n",
       "50   hangye_ZK20      专业、科研服务业          32       13.1746875   \n",
       "51   hangye_ZK30           餐饮业           6  9.6016666666667   \n",
       "52   hangye_ZK32           旅馆业           9  8.3553333333333   \n",
       "53   hangye_ZK34           旅游业          26  13.613807692308   \n",
       "54   hangye_ZK37     卫生、保健、护理业           3             53.3   \n",
       "55   hangye_ZK39         租赁服务业           5             8.76   \n",
       "56   hangye_ZK99       其他社会服务业          19  7.7473684210526   \n",
       "57   hangye_ZL01           出版业          14  7.9864285714286   \n",
       "58   hangye_ZL10       广播电影电视业          14  8.3785714285714   \n",
       "59   hangye_ZL20       信息传播服务业          11            8.693   \n",
       "60   hangye_ZL99     其他传播、文化产业           2           10.715   \n",
       "61                                       1                0   \n",
       "\n",
       "           change_amount                 Chg total_volume main_stock_code  \\\n",
       "0                  -0.08     -1.084794792985     55634877        sz300087   \n",
       "1                 -0.068   -0.57636887608069      3775708        sz300087   \n",
       "2                 -0.805    -4.8319327731092    211847467        sz300087   \n",
       "3      -0.12571428571429    -2.5829175227473    111215543        sh600257   \n",
       "4                  0.035    0.36458333333333     14984899        sh603336   \n",
       "5     -0.022178571428571   -0.40986582009465    150540777        sh601918   \n",
       "6                -0.0575    -1.1431411530815     99814885        sh601918   \n",
       "7               -0.00625   -0.10810810810811     21468170        sh600193   \n",
       "8     -0.012222222222222    -0.1345977363108    145318864        sz000758   \n",
       "9      0.045833333333333    0.57664080520025     52724746        sz002683   \n",
       "10    -0.098474747474747   -0.33147923928082    780267287        sz002626   \n",
       "11    -0.043152941176471   -0.61464112699846    381296154        sh600070   \n",
       "12     -0.13333333333333    -1.3468013468013    104113827        sz002631   \n",
       "13    0.0051923076923077   0.066894603835291    451227860        sh603022   \n",
       "14    -0.023222222222222     -0.219045840511    450879989        sh601113   \n",
       "15              -0.06464   -0.44606504931282    800568892        sz300256   \n",
       "16              -0.05706   -0.71440823434994    527828745        sh600331   \n",
       "17     -0.10372727272727   -0.80307120580332    245949309        sh603197   \n",
       "18              -0.14572   -0.86832939550044    584515681        sh600267   \n",
       "19               -0.1832    -1.7705341369033    175326565        sz300116   \n",
       "20    -0.015892307692308   -0.26720953573313    241799305        sh600116   \n",
       "21                -0.126    -1.3882767739092     35505025        sh600116   \n",
       "22    -0.058181818181818   -0.74679113185531     19635375        sh601199   \n",
       "23               -0.0138   -0.23334460601961    386018480        sz002586   \n",
       "24                -0.066   -0.88582677165354     29599870        sh603929   \n",
       "25    0.0066666666666667    0.12070006035003     19026237        sh600125   \n",
       "26    -0.020636363636364   -0.30789680709655     19298638        sh600119   \n",
       "27                 -0.09    -1.9007391763464     10932620        sh600119   \n",
       "28              -0.07175    -1.4623458677265    117142736        sz002320   \n",
       "29                -0.191    -1.7546545810877     81170883        sz200152   \n",
       "..                   ...                 ...          ...             ...   \n",
       "32                 0.175     2.6785714285714     75650519        sz300240   \n",
       "33           -0.00290625  -0.023090531020142    475282184        sh603118   \n",
       "34    0.0029411764705882   0.021700447029209    508244492        sz000977   \n",
       "35                  0.06    0.69649334945586    250092276        sh603322   \n",
       "36              -0.17663   -0.92808314548884    884875337        sz300226   \n",
       "37             -0.159375   -0.76719417534148     41325969        sz000963   \n",
       "38    -0.060576923076923   -0.89191163562437     76171501        sz000829   \n",
       "39     0.031622448979592    0.33496329347065    408674487        sz300755   \n",
       "40    -0.018189189189189   -0.24296818308176     94790877        sh600787   \n",
       "41    -0.075483870967742   -0.82475680248132    920990113        sz002142   \n",
       "42     -0.17833333333333   -0.48272128485067     70608121        sh601628   \n",
       "43  -0.00055555555555555  -0.005466422499795    355105820        sh601990   \n",
       "44                -0.065    -1.5384615384615     23422470        sh601990   \n",
       "45                     0                   0      2535700        sh601990   \n",
       "46                -0.026   -0.70327292399243     14913221        sh601990   \n",
       "47    -0.015357142857143   -0.22951029670115    577940732        sh600208   \n",
       "48                 -0.03   -0.83399523431295     71824634        sz000882   \n",
       "49   -0.0097692307692308   -0.13352959730838     24086440        sz300388   \n",
       "50            -0.0328125   -0.24843838727995    171703783        sz300070   \n",
       "51    0.0033333333333333    0.03472825143254     10606960        sz000796   \n",
       "52     0.029666666666667    0.35632782159587     10014073        sh600754   \n",
       "53    -0.048307692307692   -0.35358867164956     40355369        sh603869   \n",
       "54     -0.19333333333333   -0.36141575274177     18377825        sz300244   \n",
       "55                 -0.06   -0.68027210884354     25827862        sh600007   \n",
       "56     0.015263157894737    0.19739976856579     98302180        sz002183   \n",
       "57    -0.062142857142857   -0.77209797657082     48060961        sh600373   \n",
       "58    -0.048571428571429   -0.57636887608069     64381725        sz002905   \n",
       "59                -0.236    -2.6430731324896     88682370        sz002905   \n",
       "60                -0.065   -0.60296846011132     20679105        sh600661   \n",
       "61                     0                   0            0               0   \n",
       "\n",
       "   total_turnover main_stock_Chg current_price main_stock_change_amount  \\\n",
       "0       368469944          0.820         8.610                    0.070   \n",
       "1        30644439              0         8.610                    0.070   \n",
       "2      3436874541              0         8.610                    0.070   \n",
       "3       395833388          1.099         4.600                    0.050   \n",
       "4        81812972          0.623        14.530                    0.090   \n",
       "5       707288123         10.170         3.250                    0.300   \n",
       "6       525578399              0         3.250                    0.300   \n",
       "7        94923552          3.824         3.530                    0.130   \n",
       "8      1294614455          0.491         4.090                    0.020   \n",
       "9       483178849          3.971        14.400                    0.550   \n",
       "10    14703077001          9.875        19.360                    1.740   \n",
       "11     2614553285          9.498        10.030                    0.870   \n",
       "12      842503623          2.789         7.740                    0.210   \n",
       "13     3480396294         10.038        14.690                    1.340   \n",
       "14     2999975884          4.908         3.420                    0.160   \n",
       "15    10133319183         10.075         5.900                    0.540   \n",
       "16     2921607175         10.040         2.740                    0.250   \n",
       "17     2355922516          2.645        24.450                    0.630   \n",
       "18     7604813888          9.979        10.580                    0.960   \n",
       "19     1061588532          2.721         1.510                    0.040   \n",
       "20     1390464436          1.897         7.520                    0.140   \n",
       "21      242431835              0         7.520                    0.140   \n",
       "22      184544271          0.533         3.770                    0.020   \n",
       "23     2197007345          4.706         3.560                    0.160   \n",
       "24      184923018          1.050        14.440                    0.150   \n",
       "25       95504892          0.344         5.840                    0.020   \n",
       "26      158707207          4.469         5.610                    0.240   \n",
       "27       50774006              0         5.610                    0.240   \n",
       "28      613503394          0.726         8.320                    0.060   \n",
       "29      563032699          1.826         9.480                    0.170   \n",
       "..            ...            ...           ...                      ...   \n",
       "32      471485986          9.973         8.160                    0.740   \n",
       "33     5663280354          3.772        12.380                    0.450   \n",
       "34     6443642193          5.822        26.900                    1.480   \n",
       "35     1894054353          9.985        21.700                    1.970   \n",
       "36    13369744333          2.712        69.680                    1.840   \n",
       "37      652142013          1.484        25.990                    0.380   \n",
       "38      476887628          2.911         6.010                    0.170   \n",
       "39     3484980474          5.100        26.170                    1.270   \n",
       "40      738966773          2.299         5.340                    0.120   \n",
       "41     7510286480          1.268        27.160                    0.340   \n",
       "42     2859513318          1.820        33.000                    0.590   \n",
       "43     3920716118          2.513         8.160                    0.200   \n",
       "44       98055008              0         8.160                    0.200   \n",
       "45       15159163              0         8.160                    0.200   \n",
       "46       92924735              0         8.160                    0.200   \n",
       "47     4653411202         10.130         4.240                    0.390   \n",
       "48      220281050          3.930         2.380                    0.090   \n",
       "49      187253066          1.782        10.280                    0.180   \n",
       "50     1410571102          5.184         7.710                    0.380   \n",
       "51       61974947          2.532         6.480                    0.160   \n",
       "52      145201848          3.879        22.230                    0.830   \n",
       "53      732070455          2.597        13.430                    0.340   \n",
       "54      893115108          1.403        21.690                    0.300   \n",
       "55      144127520          0.882        17.150                    0.150   \n",
       "56      561450175          2.626         4.690                    0.120   \n",
       "57      377126280          1.623        11.900                    0.190   \n",
       "58      472582627          1.350        15.020                    0.200   \n",
       "59      874242843              0        15.020                    0.200   \n",
       "60       67799874          0.273        18.400                    0.050   \n",
       "61              0              0             0                        0   \n",
       "\n",
       "   main_stock_name  \n",
       "0             荃银高科  \n",
       "1             荃银高科  \n",
       "2             荃银高科  \n",
       "3             大湖股份  \n",
       "4             宏辉果蔬  \n",
       "5             新集能源  \n",
       "6             新集能源  \n",
       "7             ST创兴  \n",
       "8             中色股份  \n",
       "9             宏大爆破  \n",
       "10             金达威  \n",
       "11            浙江富润  \n",
       "12            德尔未来  \n",
       "13             新通联  \n",
       "14            ST华鼎  \n",
       "15            星星科技  \n",
       "16            宏达股份  \n",
       "17            保隆科技  \n",
       "18            海正药业  \n",
       "19            坚瑞沃能  \n",
       "20            三峡水利  \n",
       "21            三峡水利  \n",
       "22            江南水务  \n",
       "23            ST围海  \n",
       "24            亚翔集成  \n",
       "25            铁龙物流  \n",
       "26           *ST长投  \n",
       "27           *ST长投  \n",
       "28            海峡股份  \n",
       "29            山 航Ｂ  \n",
       "..             ...  \n",
       "32             飞力达  \n",
       "33            共进股份  \n",
       "34            浪潮信息  \n",
       "35            超讯通信  \n",
       "36            上海钢联  \n",
       "37            华东医药  \n",
       "38            天音控股  \n",
       "39            华致酒行  \n",
       "40            中储股份  \n",
       "41            宁波银行  \n",
       "42            中国人寿  \n",
       "43            南京证券  \n",
       "44            南京证券  \n",
       "45            南京证券  \n",
       "46            南京证券  \n",
       "47            新湖中宝  \n",
       "48            华联股份  \n",
       "49            国祯环保  \n",
       "50             碧水源  \n",
       "51            凯撒旅游  \n",
       "52            锦江酒店  \n",
       "53            新智认知  \n",
       "54            迪安诊断  \n",
       "55            中国国贸  \n",
       "56           怡 亚 通  \n",
       "57            中文传媒  \n",
       "58            金逸影视  \n",
       "59            金逸影视  \n",
       "60            昂立教育  \n",
       "61              --  \n",
       "\n",
       "[62 rows x 13 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "code='sh600519'\n",
    "content=sina_get_stock_info(code)\n",
    "ctx=sina_get_stock_info_api(code)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('贵州茅台',\n",
       " '600519',\n",
       " <div class=\"hq_related blue_l a_blue_d_all\" id=\"abhbk\"></div>)"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sina_stock_parse(content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "start=sina_stock_api_parse(ctx)[0].find('\"')\n",
    "end=sina_stock_api_parse(ctx)[0].find('\"',-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['贵州茅台',\n",
       " '1168.000',\n",
       " '1211.000',\n",
       " '1170.000',\n",
       " '1187.500',\n",
       " '1160.000',\n",
       " '1169.990',\n",
       " '1170.000',\n",
       " '5915059',\n",
       " '6935972684.000',\n",
       " '3900',\n",
       " '1169.990',\n",
       " '100',\n",
       " '1169.940',\n",
       " '1000',\n",
       " '1169.880',\n",
       " '100',\n",
       " '1169.690',\n",
       " '200',\n",
       " '1169.660',\n",
       " '468',\n",
       " '1170.000',\n",
       " '100',\n",
       " '1170.050',\n",
       " '2631',\n",
       " '1170.490',\n",
       " '100',\n",
       " '1170.500',\n",
       " '300',\n",
       " '1171.000',\n",
       " '2019-10-16',\n",
       " '15:00:00',\n",
       " '00',\n",
       " '']"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sina_stock_api_parse(ctx)[0][start+1:end-1].split(',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
